package com.atcumt.QiAnXin;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String s = reader.readLine();
        String ss = s.substring(1, s.length() - 1);
        int[] nums = Arrays.stream(ss.split(",")).mapToInt(Integer::valueOf).toArray();

        int i = 0, j = nums.length - 1;
        int res = 0;

        while (i < j) {
            res = nums[i] < nums[j] ? Math.max(res, (j - i) * nums[i++]) : Math.max(res, (j - i) * nums[j--]);
        }
        System.out.println(res);
    }

    static List<List<Integer>> res = new ArrayList<>();
    public int DagPathNum (int[][] nodes) {
        // write code here
        List<Integer> temp = new ArrayList<>();
        dfs(temp, nodes, 0);
        int size = res.size();
        return size;
    }

    public static void dfs(List<Integer> temp, int[][] nodes, int start) {
        if (start == nodes.length - 1) {
            temp.add(start);
            res.add(new ArrayList<>(temp));
            return;
        }
        temp.add(start);
        for (int i = 0; i < nodes[start].length; i++) {
            dfs(temp, nodes, nodes[start][i]);
            temp.remove(temp.size() - 1);
        }
    }
}
